package com.apesource.project02.controller;

import com.apesource.project02.pojo.Message;
import com.apesource.project02.service.IMessageService;
import com.apesource.project02.util.ResponseEntity;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @version 1.0
 * @auther:暮雪
 * @date:2025/9/19
 */
@RestController
@RequestMapping("/message")
public class MessageController {
    @Autowired
    private IMessageService messageService;

    @GetMapping("{userId}")
    public ResponseEntity<List<Message>> getMessages(@PathVariable int userId) {

        return messageService.getAllMessages(userId);

    }

    @RequestMapping("/search")
    public ResponseEntity<List<Message>> searchMessages(@RequestBody String keyWord) {
        return messageService.getMessageByKeyWord(keyWord);
    }
}
